import httpService from './http-service.js'

import { requestMethodCreator, $BASE_URL } from './request-method-creator.js'

export const $GET =     requestMethodCreator('get')    //GET方法
export const $POST =    requestMethodCreator('post')  //POST方法
export const $DELETE =  requestMethodCreator('delete')  //POST方法
export const $PUT =     requestMethodCreator('put')  //POST方法

//导出上传文件方法
export function $UploadFile(API, params) {
  const config = {
    method: 'post',
    url: $BASE_URL + API,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: params
  }
  return httpService(config).then((res)=>{
    return Promise.resolve(res)
  }).catch((error)=>{
    return Promise.reject(error)
  })
}